<div [@routerTransition]>
    <div class="m-subheader">
        <div class="d-flex align-items-center">
            <div class="mr-auto col-xs-6">
                <h3 class="m-subheader__title m-subheader__title--separator">
                    <span>批次管理</span>
                </h3>
                <span class="m-section__sub">
                    批次管理文本头信息
                </span>
                <!-- <label> 选择型号：</label>
                                <select name="model" class="form-control" style="display: inline-block; width: 200px;" (change)="onModelChange($event)"
                                    [(ngModel)]="selectModelId">
                                    <option value="0">全部</option>
                                    <option *ngFor="let model of models" [value]="model.value"> {{ model.displayText }} </option>
                                </select> -->
            </div>
            <div class="col-xs-6 text-right">
                <!-- <button (click)="exportToExcel()" class="btn btn-outline-success"><i class="fa fa-file-excel-o"></i>
                    {{l("ExportToExcel")}}</button> -->
                <button (click)="createOrEditPiciModal.show()" class="btn btn-primary">
                    <i class="fa fa-plus"></i>创建新的批次
                </button>
            </div>
        </div>
    </div>
    <div class="m-content">
        <div class="m-portlet m-portlet--mobile">
            <div class="m-portlet__body">
                <form class="horizontal-form" autocomplete="off">
                    <div class="m-form m-form--label-align-right">
                        <div class="row align-items-center m--margin-bottom-10">
                            <div class="col-xl-12">
                                <div class="form-group m-form__group align-items-center">
                                    <div class="input-group">
                                        <input
                                            [(ngModel)]="filterText"
                                            name="filterText"
                                            autoFocus
                                            class="form-control m-input"
                                            [placeholder]="l('SearchWithThreeDot')"
                                            type="text"
                                        />
                                        <span class="input-group-btn">
                                            <button (click)="getPicis()" class="btn btn-primary" type="submit">
                                                <i class="flaticon-search-1" [attr.aria-label]="l('Search')"></i>
                                            </button>
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>

                <div class="row align-items-center">
                    <!--<Primeng-TurboTable-Start>-->
                    <div class="primeng-datatable-container" [busyIf]="primengTableHelper.isLoading">
                        <p-table
                            #dataTable
                            (onLazyLoad)="getPicis($event)"
                            [value]="primengTableHelper.records"
                            rows="{{ primengTableHelper.defaultRecordsCountPerPage }}"
                            [paginator]="false"
                            [lazy]="true"
                            [scrollable]="true"
                            ScrollWidth="100%"
                            [responsive]="primengTableHelper.isResponsive"
                            [resizableColumns]="primengTableHelper.resizableColumns"
                        >
                            <ng-template pTemplate="header">
                                <tr>
                                    <th
                                        style="width: 130px"
                                        [hidden]="
                                            !isGrantedAny(
                                                'Pages.Administration.Users.Impersonation',
                                                'Pages.Administration.Users.Edit',
                                                'Pages.Administration.Users.ChangePermissions',
                                                'Pages.Administration.Users.Delete'
                                            )
                                        "
                                    >
                                        {{ l("Actions") }}
                                    </th>
                                    <th style="width: 150px" pSortableColumn="name">
                                        {{ l("Name") }}
                                        <p-sortIcon field="name"></p-sortIcon>
                                    </th>
                                    <th style="width: 150px" pSortableColumn="quantity">
                                        数量
                                        <p-sortIcon field="quantity"></p-sortIcon>
                                    </th>
                                    <th style="width: 150px" pSortableColumn="model">
                                        型号
                                        <p-sortIcon field="model"></p-sortIcon>
                                    </th>

                                    <th style="width: 600px">
                                        任务前缀
                                    </th>
                                </tr>
                            </ng-template>
                            <ng-template pTemplate="body" let-record="$implicit">
                                <tr>
                                    <td style="width: 130px">
                                        <div class="btn-group dropdown" dropdown container="body">
                                            <button dropdownToggle class="dropdown-toggle btn btn-sm btn-primary">
                                                <i class="fa fa-cog"></i><span class="caret"></span> {{ l("Actions") }}
                                            </button>
                                            <ul class="dropdown-menu" *dropdownMenu>
                                                <li>
                                                    <a
                                                        href="javascript:;"
                                                        (click)="createOrEditPiciModal.show(record.id)"
                                                        >{{ l("Edit") }}</a
                                                    >
                                                </li>

                                                <li>
                                                    <a href="javascript:;" (click)="deletePici(record)">{{
                                                        l("Delete")
                                                    }}</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </td>
                                    <td style="width: 150px">
                                        <span class="ui-column-title"> {{ l("Name") }}</span>
                                        {{ record.name }}
                                    </td>
                                    <td style="width: 150px">
                                        <span class="ui-column-title"> 数量</span>
                                        {{ record.quantity }}
                                    </td>
                                    <td style="width: 150px">
                                        <span class="ui-column-title"> 型号</span>
                                        {{ record.model }}
                                    </td>
                                    <td style="width: 600px">
                                        <span class="ui-column-title"> 任务前缀</span>
                                        <span *ngIf="record.taskPrefixes">
                                            <span
                                                class="m-badge m-badge--success m-badge--wide"
                                                style="margin-left: 5px; margin-right: 5px;"
                                                *ngFor="let preFix of record.taskPrefixes.split(',')"
                                            >
                                                {{ preFix }}</span
                                            >
                                        </span>
                                    </td>
                                </tr>
                            </ng-template>
                        </p-table>
                        <div class="primeng-no-data" *ngIf="primengTableHelper.totalRecordsCount == 0">
                            {{ l("NoData") }}
                        </div>
                        <div class="primeng-paging-container">
                            <p-paginator
                                rows="{{ primengTableHelper.defaultRecordsCountPerPage }}"
                                #paginator
                                (onPageChange)="getPicis($event)"
                                [totalRecords]="primengTableHelper.totalRecordsCount"
                                [rowsPerPageOptions]="primengTableHelper.predefinedRecordsCountPerPage"
                            >
                            </p-paginator>
                            <span class="total-records-count">
                                {{ l("TotalRecordsCount", primengTableHelper.totalRecordsCount) }}
                            </span>
                        </div>
                    </div>
                    <!--<Primeng-TurboTable-End>-->
                </div>
            </div>
        </div>
    </div>

    <createOrEditPiciModal #createOrEditPiciModal (modalSave)="getPicis()"></createOrEditPiciModal>
</div>
